require"lfs"

function attrdir(path)
  for file in lfs.dir(path) do
    if file ~= "." and file ~= ".." then 
      local f = path.. '/' ..file
      local attr = lfs.attributes (f)
      if attr.mode == "directory" then
          print(f .. "  -->  " .. attr.mode)
          attrdir(f)
      else
          print(f .. "  -->  " .. attr.mode)
      end
    end
  end
end

function copyFunc(sourcePath, targetPath)
	local rf = io.open(sourcePath,"rb")
	local len = rf:seek("end")
	rf:seek("set",0)
	local data = rf:read(len)
	local wf = io.open(targetPath,"wb")
	wf:write(data,len)
	rf:close()
	wf:close()
end

function split( str,reps )
  local resultStrList = {}
  string.gsub(str,'[^'..reps..']+',function ( w )
      table.insert(resultStrList,w)
  end)
  return resultStrList
end

function string.split(input, delimiter)
  input = tostring(input)
  delimiter = tostring(delimiter)
  if (delimiter=='') then return false end
  local pos,arr = 0, {}
  for st,sp in function() return string.find(input, delimiter, pos, true) end do
      table.insert(arr, string.sub(input, pos, st - 1))
      pos = sp + 1
  end
  table.insert(arr, string.sub(input, pos))
  return arr
end
